package tech.yangzhijie.basic.thread;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.concurrent.TimeUnit;

public class SleepTaskRunnable implements Runnable {

    @Override
    public void run() {
        System.out.println(LocalDateTime.now());
        int sleeptime = (int)Math.ceil(Math.random()*10);
        try {
            System.out.println(Thread.currentThread().getName()+"sleep "+sleeptime+" 秒");
            TimeUnit.MILLISECONDS.sleep(sleeptime*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(LocalDateTime.now());
    }
}
